#pragma once

class CritSect
{
public:
	CritSect();
	~CritSect();

	void Lock();
	void Unlock();
	
protected:
	CRITICAL_SECTION m_cs;	
};

class AutoLock
{
public:
	AutoLock(CritSect* cs);
	~AutoLock();

protected:
	CritSect* m_cs;
};

class MyEvent
{
public:
	MyEvent(BOOL manual = FALSE);
	~MyEvent();

	operator HANDLE () const;

	void Set();
	BOOL Wait(DWORD tmout = INFINITE);
	void Reset();
	BOOL Check();

protected:
    HANDLE m_hEvt;
};

class MsgEvent : public MyEvent
{
public:
	BOOL WaitMsg(DWORD tmout = INFINITE);
};
